package com.share.example.selenium.enums;

import lombok.Getter;

import java.util.Optional;

/**
 * @author syq
 * @data 2019/6/17
 */
@Getter
public enum BusinessEnum {
    DEFAULT("default", "默认窗口"),
    AMAZON_BUY("amazon_buy", "亚马逊-买家系统"),
    AMAZON_SELLER("amazon_seller", "亚马逊-商家系统"),
    HZHC_HM("hzhc_hm", "汉辰信息-统一登录系统"),
    HZHC_TASK("hzhc_task", "汉辰信息-任务系统,通过账号密码登录"),
    HZHC_TASK_V2("hzhc_task_v2", "汉辰信息-任务系统,通过用户中心跳转登录"),
    HZHC_DINGDING_STUDY("hzhc_dingding_study", "汉辰信息-统一登录系统"),
    HZHC_ZHIBO_0921("hzhc_zhibo_0921", "业务直播");


    public String code;
    public String name;

    BusinessEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static BusinessEnum toEnum(final String code) {
        for (final BusinessEnum tag : BusinessEnum.values()) {
            if (tag.code.equals(code)) {
                return tag;
            }
        }
        return null;
    }

    public static String toName(final String code) {
        return Optional.ofNullable(toEnum(code)).map(item -> item.name).orElse(null);
    }
}
